<?php

namespace Sifast\ProjectBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;

class DependantsAdmin extends Admin
{
 
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->with('L1')
            ->add('nom','text',array(
                'label'=>'Nom:',
            ))
            ->add('prenom','text',array(
                'label'=>'Prénom:',
            ))
            ->end() 
            ->with('L2')    
            ->add('relation', 'choice', array(
                    'label'=> 'Relation:',
                    'choices' => array(
                        'Choisir la relation' => 'Choisir la relation',
                        'Conjoint' => 'Conjoint',
                        'Enfant' => 'Enfant',
                        'Pére' => 'Pére',
                        'Mére' => 'Mére',
                        'Autre' => 'Autre',
                    )
                ))
            ->add('dateNaissance', 'date', array(
                    'label'=> 'Date de naissance:',
                    'widget' => 'single_text',
                    'format' => 'MM/dd/yyyy',
                    'attr' => array('class' => 'datepicker')
                ))
            ->end()
            ->with('L3')    
            ->add('dateDeces', 'date', array(
                    'label'=> 'Date de décés:',
                    'widget' => 'single_text',
                    'format' => 'MM/dd/yyyy',
                    'attr' => array('class' => 'datepicker')
                ))
            ->end()    ;
            
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
           ->add('nom')
            ->add('prenom')
            ->add('relation')
            ->add('dateNaissance') 
            ->add('dateDeces');
            
    }

    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            
            ->addIdentifier('nom')
            ->add('prenom')
            ->add('relation')
            ->add('dateNaissance') 
            ->add('dateDeces');
            
            }
}